#@layoutT('')
#define main()
<div class="container-wrap">
   #@formStart()
   #@queryStart('处理状态')
   <input type="search" name="status" autocomplete="off" class="layui-input" placeholder="设备ID"/>
   #@queryEnd()
   #@queryStart('设备编号')
   <input type="search" name="devideid" autocomplete="off" class="layui-input" placeholder="设备编号"/>
   #@queryEnd()
   #@queryStart('预警类型')
   <input type="search" name="message" autocomplete="off" class="layui-input" placeholder="预警类型"/>
   #@queryEnd()
   #@formEnd()

   #@table()

   #@subTable(['用户信息','设备信息'])
</div>
#end

#define js()

<!-- 引入从表js-->
#@subTableJs()
<!-- 分页表格 -->
<script>
    gridArgs.title='';
    gridArgs.dataId='id';
    gridArgs.deleteUrl='#(path)/portal/business/iWarningList/delete';
    gridArgs.updateUrl='#(path)/portal/business/iWarningList/edit/';
    gridArgs.addUrl='#(path)/portal/business/iWarningList/add';
    gridArgs.heightDiff=250;
    gridArgs.gridDivId ='maingrid';
    initGrid({id : 'maingrid'
        ,elem : '#maingrid'
        ,toolbar:'#table_toolbar'//开启头部工具栏，并为其绑定左侧模板
        ,cellMinWidth: 100
        ,cols : [ [
				 {title:'预警时间',field:'warningtime'},
				 {title:'预警类型',field:'warntype',width : 40},
				 {title:'处理状态',field:'status',width : 35},
				 {title:'预警信息',field:'message'},
				 {title:'处理结果',field:'dealmessage'},
				 {title:'处理人',field:'dealuser'},
				 {title: '主键',field : 'id',width : 35,checkbox : true},
				 {title:'序号',type:'numbers',width:35},
            {fixed:'right',width : 180,align : 'left',toolbar : '#bar_maingrid'}
            ] ]
        ,url:"#(path)/portal/business/iWarningList/list"
        ,searchForm : 'searchForm'
    });



    function renderSubTable1(orgId){
       //获取默认配置
       var config=editTable.config;
       //查询数据接口
       config.queryUrl="#(path)/portal/business/iCustomerInfo/list";
       config.params={"idcard":orgId};
       //表格列表设置
       editTable.render(config,{
          elem: '#'+config.tableId
          ,height: '300'
          ,cols: [[
             {title:'序号',type:'numbers',width:35}
             ,{field:'customername',align:'center', title: '姓名' }
             ,{field:'phonenum', title: '手机 ' }
             ,{field:'idcard', title: '证件号'}
             ,{field:'devideid', title: '设备ID'}
          ]]
       });

    }

    function renderSubTable2(orgId){
       // var editTable=new EditTable();
       // var config=editTable.config;
       // //查询数据接口
       // config.queryUrl="#(path)/portal/business/iDeviceInfo/list";
       // config.params={"devideid":orgId};
       var editTable=new EditTable();
       var config=editTable.config;
       //除了第一个用默认配置,其他表格都要配置自己的参数
       config.tableId='tab_item_2';//表Id
       config.addBtnId='add_btn_2';//添加按钮ID
       config.delEvent='del_btn_2';//删除按钮Even值
       config.delBtnId='del_btn_2';
       config.toolbar='table_toolbar_2';//表头工具ID
       config.rowbar='table_rowbar_2';//行按钮ID
       config.saveBtnId="save_btn_2";//保存表格接口
       config.queryUrl="#(path)/portal/business/iDeviceInfo/list";
       config.params={"devideid":orgId};
       // config.rowData={
       //    "user_code":"test2",
       //    "user_name":"托尔斯泰2",
       //    "org_name":null,
       //    "sex":0,
       //    "mobile":null,
       //    "tel":null,
       //    "email":null,
       //    "allow_login":1
       // };
       //表格列表设置
       editTable.render(config,{
          elem: '#'+config.tableId
          ,height: '300'
          ,cols: [[
             {title:'经度',field:'latitude'},
             {title:'纬度',field:'longitude'},
             {title:'心率',field:'heartrate'},
             {title:'体温',field:'bodytemperature'},
             {title:'收缩压',field:'systolicpressure'},
             {title:'舒张压',field:'diastolicpressure'},
             {title:'血氧',field:'bloodoxygen'},
             {title:'步数',field:'stepcount'},
          ]]
       });

    }

</script>
#end
<!-- 监听主表点击事件 -->
#define layuiFunc()
//监听行单击事件（双击事件为：rowDouble）
table.on('row(maingrid)', function(obj){
var data = obj.data;
var orgId=data.idcard;
var orgId2=data.devideid;
//渲染从表数据
renderSubTable1(orgId);
renderSubTable2(orgId2);
//标注选中样式
obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
});
#end

